<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>评论模块</title>
    <link rel="stylesheet" href="../assets/lib/layui/css/layui.css" />
    <style>
      body {
        height: 100%;
        margin: 20px;
        background-color: #eee;
      }
    </style>
  </head>
  <body>
    <div class="layui-card">
      <div class="layui-card-header">卡片面板</div>
      <div class="layui-card-body">
        <!-- 表格 -->
        <table class="layui-table">
          <colgroup>
            <col width="50" />
            <col width="200" />
            <col width="400" />
            <col width="200" />
            <col />
          </colgroup>
          <thead>
            <tr>
              <th>ID</th>
              <th>评论人</th>
              <th>评论内容</th>
              <th>评论时间</th>
              <th>操作</th>
            </tr>
          </thead>
          <tbody></tbody>
        </table>
      </div>
    </div>
    <script src="../assets/lib/jquery.js"></script>
    <script src="../assets/lib/template-web.js"></script>
    <script src="../assets/lib/layui/layui.all.js"></script>
    <script src="../assets/js/common.js"></script>
    <script src="../assets/js/comment/comment.js"></script>
    <!-- 魔板数据 -->
    <script type="text/html" id="tb-m">
      {{each data item}}
      <tr>
        <td>{{item.id}}</td>
        <td>{{item.uname}}</td>
        <td>{{item.content}}</td>
        <td>{{item.cdate|date}}</td>
        <td>
          <button
            type="button"
            class="layui-btn layui-btn-sm layui-btn-danger"
            id="dele"
            data-id="{{item.id}}"
          >
            删除
          </button>
        </td>
      </tr>
      {{/each}}
    </script>
    <script>
      // 过滤器(时间)
      template.defaults.imports.date = function (s) {
        let date = new Date(s);
        let y = date.getFullYear();
        let m = date.getMonth() + 1;
        let d = date.getDate();
        return y + "-" + m + "-" + d;
      };
    </script>
  </body>
</html>
